/*
 * Copyright (C) 2012, EADS France
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
package xowl.gmi.controller;

/**
 *
 * @author Laurent WOUTERS
 */
public abstract class NodeAction extends xowl.gmi.environment.UIAction {
    protected xowl.interpreter.Repository repository;
    protected String parent;
    protected String child;
    
    public NodeAction(String description, xowl.interpreter.Repository repository, String parent, String child) {
        super(description);
        this.repository = repository;
        this.parent = parent;
        this.child = child;
    }
    
    protected xowl.gmi.model.ast.Decorator getDecorator() {
        xowl.gmi.model.ast.ASTNode pn = xowl.gmi.model.ast.ASTNode.get(repository, parent);
        xowl.gmi.model.ast.ASTNode cn = xowl.gmi.model.ast.ASTNode.get(repository, child);
        for (xowl.gmi.model.ast.Decorator decorator : cn.getAllDecorators())
            return decorator;
        return null;
    }
}
